package net.nagaseyasuhito.kinsenka.wicket.page;

import net.nagaseyasuhito.kinsenka.wicket.KinsenkaSession;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;

public abstract class BasePage extends WebPage {
	private static final long serialVersionUID = 1L;

	public BasePage() {
		this.add(new BookmarkablePageLink<IndexPage>("index", IndexPage.class));

		this.add(new Link<Void>("signOut") {
			private static final long serialVersionUID = 1L;

			@Override
			public boolean isVisible() {
				return KinsenkaSession.get().isSignedIn();
			}

			@Override
			public void onClick() {
				KinsenkaSession.get().signOut();
				this.setResponsePage(IndexPage.class);
			}
		});
	}
}
